import React,{findDOMNode,Component,PropTypes} from 'react';

export default class AddTodo extends Component {
	constructor(props){
		super(props);
		this.handlerSubmmit=this.handlerSubmmit.bind(this);
	}
	render(){
		return (<form role="form">
			<legend>Form title</legend>
		
			<div className="form-group">
				<label for="">new todo:</label>
				<input type="text" className="form-control" ref="input" placeholder="todo "/>
			</div>
			<button type="button" onClick={this.handlerSubmmit} className="btn btn-primary">Add</button>
		</form>)
	}

	handlerSubmmit(e){
		console.log('handlerSubmmit');
		e.preventDefault();
		const node = this.refs.input;
    	const text = node.value.trim();
    	this.props.onAddClick(text);
    	node.value = '';
	}
}
AddTodo.propTypes = {
  onAddClick: PropTypes.func.isRequired
}
